package xcmg.device.web.ratingManager;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import xcmg.device.infra.BasicController;
import xcmg.device.infra.ErrorCode;
import xcmg.device.service.ratingManager.ScoreInfoDetailService;
import xcmg.device.service.vo.ratingManager.*;
import yb.ecp.fast.infra.annotation.FastMappingInfo;
import yb.ecp.fast.infra.infra.ActionResult;

import java.util.List;

/**
 * Created by Administrator on 2019/7/12.
 */
@RestController
@RequestMapping("/scoreInfoDetail")
@Api("评分信息详情信息相关入口")
public class ScoreInfoDetailController extends BasicController{
    @Autowired
    private ScoreInfoDetailService scoreInfoDetailService;

    @GetMapping(value = "getSalesCompleteDetail")
    @ApiOperation(value = "获取销售完成情况详情信息")
    @FastMappingInfo(needLogin = true)
    public ActionResult getSalesCompleteDetail(@RequestParam("scoreInfoId") String scoreInfoId) throws Exception {
        if (StringUtils.isBlank(scoreInfoId)){
            return actionResult(ErrorCode.IllegalArument);
        }
        return actionValueResult(scoreInfoDetailService.getSalesCompleteDetail(scoreInfoId));
    }

    @GetMapping(value = "getMonthPlanAccuracyDetail")
    @ApiOperation(value = "月度计划准确性详情信息")
    @FastMappingInfo(needLogin = true)
    public ActionResult getMonthPlanAccuracyDetail(@RequestParam("scoreInfoId") String scoreInfoId) throws Exception {
        if (StringUtils.isBlank(scoreInfoId)){
            return actionResult(ErrorCode.IllegalArument);
        }
        return actionValueResult(scoreInfoDetailService.getMonthPlanAccuracyDetail(scoreInfoId));
    }

    @GetMapping(value = "getOrderNormativeDetail")
    @ApiOperation(value = "订单管理规范性详情信息")
    @FastMappingInfo(needLogin = true)
    public ActionResult getOrderNormativeDetail(@RequestParam("scoreInfoId") String scoreInfoId) throws Exception {
        if (StringUtils.isBlank(scoreInfoId)){
            return actionResult(ErrorCode.IllegalArument);
        }
        return actionValueResult(scoreInfoDetailService.getOrderNormativeDetail(scoreInfoId));
    }
    @GetMapping(value = "getReceivableOverdueDetail")
    @ApiOperation(value = "应收账款逾期详情信息")
    @FastMappingInfo(needLogin = true)
    public ActionResult getReceivableOverdueDetail(@RequestParam("scoreInfoId") String scoreInfoId) throws Exception {
        if (StringUtils.isBlank(scoreInfoId)){
            return actionResult(ErrorCode.IllegalArument);
        }
        return actionValueResult(scoreInfoDetailService.getReceivableOverdueDetail(scoreInfoId));
    }
    @GetMapping(value = "getOverallCompleteDetail")
    @ApiOperation(value = "总体销售完成率详情信息")
    @FastMappingInfo(needLogin = true)
    public ActionResult getOverallCompleteDetail(@RequestParam("scoreInfoId") String scoreInfoId) throws Exception {
        if (StringUtils.isBlank(scoreInfoId)){
            return actionResult(ErrorCode.IllegalArument);
        }
        return actionValueResult(scoreInfoDetailService.getOverallCompleteDetail(scoreInfoId));
    }

    @GetMapping(value = "getStockBusinessDetail")
    @ApiOperation(value = "库存管理及业务规范性加减分详情信息")
    @FastMappingInfo(needLogin = true)
    public ActionResult getStockBusinessDetail(@RequestParam("scoreInfoId") String scoreInfoId) throws Exception {
        if (StringUtils.isBlank(scoreInfoId)){
            return actionResult(ErrorCode.IllegalArument);
        }
        return actionValueResult(scoreInfoDetailService.getStockBusinessDetail(scoreInfoId));
    }


    @PostMapping(value = "/updateSalesCompleteDetail")
    @ApiOperation(value = "修改获取销售完成情况详情信息")
    @FastMappingInfo(needLogin = true)
    public ActionResult updateSalesCompleteDetail(@RequestBody List<SalesCompleteDetailVO> voList) throws Exception {
        if (null == voList || voList.isEmpty()){
            return actionResult(ErrorCode.IllegalArument);
        }

        return actionResult(scoreInfoDetailService.updateSalesCompleteDetail(voList));
    }

    @PostMapping(value = "/updateMonthPlanAccuracyDetail")
    @ApiOperation(value = "修改月度计划准确性详情信息")
    @FastMappingInfo(needLogin = true)
    public ActionResult updateMonthPlanAccuracyDetail(@RequestBody MonthPlanAccuracyDetailVO vo) throws Exception {
        if (null == vo){
            return actionResult(ErrorCode.IllegalArument);
        }

        return actionResult(scoreInfoDetailService.updateMonthPlanAccuracyDetail(vo));
    }


    @PostMapping(value = "/updateStockBusinessDetail")
    @ApiOperation(value = "修改库存管理及业务规范性加减分详情信息")
    @FastMappingInfo(needLogin = true)
    public ActionResult updateStockBusinessDetail(@RequestBody StockBusinessDetailVO vo) throws Exception {
        if (null == vo){
            return actionResult(ErrorCode.IllegalArument);
        }

        return actionResult(scoreInfoDetailService.updateStockBusinessDetail(vo));
    }

    @PostMapping(value = "/updateOrderNormativeDetail")
    @ApiOperation(value = "修改订单管理规范性详情信息")
    @FastMappingInfo(needLogin = true)
    public ActionResult updateOrderNormativeDetail(@RequestBody OrderNormativeDetailVO vo) throws Exception {
        if (null == vo){
            return actionResult(ErrorCode.IllegalArument);
        }

        return actionResult(scoreInfoDetailService.updateOrderNormativeDetail(vo));
    }

    @PostMapping(value = "/updateReceivableOverdueDetail")
    @ApiOperation(value = "修改应收账款逾期详情信息")
    @FastMappingInfo(needLogin = true)
    public ActionResult updateReceivableOverdueDetail(@RequestBody ReceivableOverdueDetailVO vo) throws Exception {
        if (null == vo){
            return actionResult(ErrorCode.IllegalArument);
        }

        return actionResult(scoreInfoDetailService.updateReceivableOverdueDetail(vo));
    }

    @PostMapping(value = "/updateOverallCompleteDetail")
    @ApiOperation(value = "修改总体销售完成率详情信息")
    @FastMappingInfo(needLogin = true)
    public ActionResult updateOverallCompleteDetail(@RequestBody OverallCompleteDetailVO vo) throws Exception {
        if (null == vo){
            return actionResult(ErrorCode.IllegalArument);
        }

        return actionResult(scoreInfoDetailService.updateOverallCompleteDetail(vo));
    }

}
